home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / clonetab.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  1.9 KB  |  54 lines

  1. //---------------------------------------------------------------------------
  2. //Borland C++Builder
  3. //Copyright (c) 1987, 1998 Borland International Inc. All Rights Reserved.
  4. //---------------------------------------------------------------------------
  5. //---------------------------------------------------------------------------
  6. #include <vcl.h>
  7. #pragma hdrstop
  8.  
  9. #include "CloneTab.h"
  10.  
  11.  
  12. __fastcall TCloneTable::TCloneTable(TComponent* AOwner,bool Reset) : TTable(AOwner)
  13. {
  14.      InitFromTable(dynamic_cast <TTable*>(AOwner), Reset);
  15. }
  16.  
  17. void __fastcall TCloneTable::InitFromTable(TTable* SourceTable, bool Reset)
  18. {
  19.     TableName = SourceTable->TableName;
  20.     DatabaseName = SourceTable->DatabaseName;
  21.     if (IndexName != "") IndexName = SourceTable->IndexName;
  22.     else if (IndexFieldNames != "") IndexFieldNames = SourceTable->IndexFieldNames;
  23.     SetSourceHandle(SourceTable->Handle);
  24.     Filter = SourceTable->Filter;
  25.     OnFilterRecord = SourceTable->OnFilterRecord;
  26.     Filtered = SourceTable->Filtered;
  27.  
  28.     if (Reset) {
  29.         Filtered = false;  //turn off filters
  30.         DbiResetRange(FSourceHandle); // kill ranges
  31.         IndexName = ""; // kill indexes
  32.         First();        // put clone table at first record
  33.     }
  34. }
  35.  
  36. void __fastcall TCloneTable::SetSourceHandle(hDBICur ASourceHandle)
  37. {
  38.     if (ASourceHandle != FSourceHandle) { // if not same cursor
  39.         Close();                        // close table first if open
  40.         FSourceHandle = ASourceHandle; // Clone handle cursor = sourcetable cursor
  41.         if (FSourceHandle)
  42.          Open(); // if not null
  43.    }
  44. }
  45.  
  46. hDBICur __fastcall TCloneTable::CreateHandle() // this creates the Clone cursor handle
  47. {
  48.    hDBICur Cur;         //FSourceHandle should hold the source handle
  49.    Check(DbiCloneCursor(FSourceHandle, false, false, Cur));
  50.    return Cur;  //return clone cursor
  51. }
  52.  
  53.  
  54.